﻿@model Telerik.Web.Mvc.GridModel<EmailAccountModel>
@using Telerik.Web.Mvc.UI
@{
    ViewBag.Title = T("Admin.Configuration.EmailAccounts").Text;
}
<div class="section-header">
    <div class="title">
        <i class="fa fa-envelope"></i>
        @T("Admin.Configuration.EmailAccounts")
    </div>
    <div class="options">
        <a href="@Url.Action("Create")" class="btn btn-primary">
			<i class="fa fa-plus"></i>
			<span>@T("Admin.Common.AddNew")</span>
		</a>
    </div>
</div>
@(Html.Telerik().Grid<EmailAccountModel>()
        .Name("emailAccounts-grid")
        .DataKeys(x =>
        {
            x.Add(y => y.Id).RouteKey("Id");
        })
        .BindTo(Model.Data)
        .Columns(columns =>
        {
			columns.Bound(x => x.Email)
				.Template(x => Html.ActionLink(x.Email, "Edit", new { id = x.Id }))
				.ClientTemplate("<a href=\"Edit/<#= Id #>\"><#= Email #></a>")
				.Width(400);
            columns.Bound(x => x.DisplayName);
			columns.Bound(x => x.Host);
			columns.Bound(x => x.Port)
				.Centered();
			columns.Bound(x => x.EnableSsl)
				.Template(item => @Html.SymbolForBool(item.EnableSsl))
				.ClientTemplate(@Html.SymbolForBool("EnableSsl"))
				.Centered();
			columns.Bound(x => x.IsDefaultEmailAccount)
                .Centered()
				.Template(
				@<a href='@Url.Action("List", new { id = item.Id })' class="btn btn-block btn-secondary" @Html.Attr("disabled", "disabled", item.IsDefaultEmailAccount) title='@T("Admin.Configuration.EmailAccounts.Fields.MarkAsDefaultEmail").Text'>
					@if (item.IsDefaultEmailAccount)
					{
						<i class="fa fa-fw fa-check"></i>
					}
				 	<span>
				 		@T("Admin.Telerik.GridLocalization.Select")
					</span>
				</a>
				)
                .Width(100).HtmlAttributes(new { align = "right" });
        })
	)